package com.ry.est.service.impl;

import com.ry.est.constants.Constants;
import com.ry.est.dao.EvaluateDetailDao;
import com.ry.est.dto.EvaluateDetailDTO;
import com.ry.est.entity.EvaluateDetail;
import com.ry.est.service.EvaluateDetailService;
import com.ry.est.util.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author ry
 * @since 2021-11-09 10:04
 **/
@Service
public class EvaluateDetailServiceImpl implements EvaluateDetailService {
    @Autowired
    private EvaluateDetailDao evaluateDetailDao;
    @Override
    public int saveEvaluateDetail(EvaluateDetail evaluateDetail) {
        evaluateDetail.setCreatedTime(new Date());
        evaluateDetail.setIsDelete(Constants.EST_NOT);
        return evaluateDetailDao.insert(evaluateDetail);
    }

    @Override
    public List<EvaluateDetailDTO> listByEvaluateId(Long evaluateId) {
        List<EvaluateDetail> evaluateDetails = evaluateDetailDao.listByEvaluateId(evaluateId);

        List<EvaluateDetailDTO> evaluateDetailDTOS = BeanUtils.convertToDTOList(evaluateDetails, EvaluateDetailDTO.class);
        return evaluateDetailDTOS;
    }
}
